home *** CD-ROM | disk | FTP | other *** search
/ Shareware Super Platinum 8 / Shareware Super Platinum 8.iso / mac / PROGTOOL / GWMALLOC.ZIP;1 / GWMALLOC.TAR / gw_malloc / NOTES < prev    next >
Encoding:
Text File  |  1993-04-08  |  4.1 KB  |  105 lines

  1. -------------------------------------------------------------------------------
  2. $Id: NOTES,v 1.13 1993/04/06 04:24:29 gray Exp $
  3. -------------------------------------------------------------------------------
  4.  
  5. WARNINGS:
  6.  
  7. - do not be surprised if the library catches problems with your
  8.     system's library routines.  It took me 6 hours once to finally
  9.     come to the conclusion that the localtime call, included in
  10.     SunOS release 4.1 (and maybe before/after), was overwriting
  11.     one of its fence-post markers.
  12.  
  13. -------------------------------------------------------------------------------
  14.  
  15. GENERAL:
  16.  
  17. - dumping core on errors and then continuing did not look to be a problem to
  18.     implement.  However it became "not recommended" as soon as it was
  19.     discovered that fork (which is needed) calls malloc itself.  If the
  20.     heap was corrupted or some other critical error has occurred then the
  21.     library would quickly go recursive.
  22.  
  23. - administration blocks are relocatable:
  24.     - any administration blocks are relocatable in the heap which means
  25.         that if we monitor the freeing of a block we have the
  26.         opportunity to swap a higher admin block down which would mean
  27.         we could possible locate as many admin blocks as possible in
  28.         low memory making more contiguous usable areas
  29.  
  30.     - you have the freed blocks address
  31.  
  32.     - as you go through the admin blocks, until you get to the right entry,
  33.         save a pointer to the highest (or lowest) one
  34.  
  35.     - when you find the free block, find out if it is lower (or higher)
  36.         than the highest admin block and bcopy the admin block down and
  37.         redo the pointers
  38.  
  39. -------------------------------------------------------------------------------
  40.  
  41. CODING WARNINGS:
  42.  
  43. - watch for heaps growing up or down (all subtraction or other position
  44.     dependent code must be changed to macros in heap.h) >,<,-,+,etc
  45. - watch for bounds checking assuming + or - code.
  46.  
  47. -------------------------------------------------------------------------------
  48.  
  49. CHUNK INFORMATION:
  50.  
  51. - it is assumed that none of the __FILE__ arguments are on the heap because
  52.     to determine whether a dblock is free or not it looks at the next
  53.     argument (unioned with the file argument) and sees if it is null or
  54.     in the heap meaning it is at the end or middle of a free list.
  55.  
  56.  
  57. -------------------------------------------------------------------------------
  58.  
  59. DBLOCK METHOD:
  60.  
  61. - have the bblock admin struct point to the dblock admin structure block which
  62.     contains a number of dblock admin entries.
  63. - have a global pointer that points to last free dblock admin structure entry
  64.     and has a count of the number left in the block
  65. - only allocate contiguous dblock admin slots so have some fragmentation
  66.     - must have contiguous because bblocks do not have pointer to start of
  67.         array
  68. - maybe have a sorted free list of the number of free dblock admin structs.
  69.     sorted in descending order
  70. - you have the free pointer which gets you to the bblock where you can see if
  71.     it is a dblock and if it is on the correct boundary.  Then you go to
  72.     the dblock admin struct to get the file, line, size info.
  73. - the bblock tells you of the number of bits in the chunk, etc.
  74. - have some way to run through the dblock admin slot blocks to verify that
  75.     crc's have not been overwritten.
  76.  
  77. -------------------------------------------------------------------------------
  78.  
  79. NEW ALGORITHMS:
  80.  
  81. - maybe have some sort of bitmask for free space/used space like BSD disk
  82.     blocks
  83. - look in your free_list for first block.
  84.     - if NULL then move up a bin and try to divide
  85.     - continue until up X blocks then sbrk a new smaller block
  86. - maybe try a finite number of free_bins above the one you want to limit
  87.     fragmentation, test this thing
  88.  
  89. -------------------------------------------------------------------------------
  90.  
  91. OVERHEAD:
  92.  
  93. - dblock: 8 bytes per pointer
  94. - bblock: 12 bytes per pointer
  95.  
  96. -------------------------------------------------------------------------------
  97.  
  98. THANKS:
  99.  
  100. Special thanks to Scott Michel <scottm@intime.intime.COM> for
  101. listening to my endless chatter and finding/solvings lots of stupid
  102. problems during the alpha stages of this library.
  103.  
  104. -------------------------------------------------------------------------------
  105.